<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
	<meta name="keywords" content="kubernetes,ops" />
	<meta name="description" content="使用 Kubernetes 部署 Seata Server" />
	<!-- 网页标签标题 -->
	<title>使用 Kubernetes 部署 Seata Server</title>
  <link rel="shortcut icon" href="/img/seata_logo_small.jpeg"/>
	<link rel="stylesheet" href="/build/documentation.css" />
</head>
<body>
	<div id="root"><div class="documentation-page" data-reactroot=""><header class="header-container header-container-normal"><div class="header-body"><a href="/zh-cn/index.html"><img class="logo" src="/img/seata_logo.png"/></a><div class="search search-normal"><span class="icon-search"></span></div><span class="language-switch language-switch-normal">En</span><div class="header-menu"><img class="header-menu-toggle" src="/img/system/menu_gray.png"/><ul><li class="menu-item menu-item-normal"><a href="/zh-cn/index.html" target="_self">首页</a></li><li class="menu-item menu-item-normal menu-item-normal-active"><a href="/zh-cn/docs/overview/what-is-seata.html" target="_self">文档</a></li><li class="menu-item menu-item-normal"><a href="/zh-cn/docs/developers/developers_dev.html" target="_self">开发者</a></li><li class="menu-item menu-item-normal"><a href="/zh-cn/blog/index.html" target="_self">博客</a></li><li class="menu-item menu-item-normal"><a href="/zh-cn/community/index.html" target="_self">社区</a></li><li class="menu-item menu-item-normal"><a href="/zh-cn/blog/download.html" target="_self">下载</a></li></ul></div></div></header><div class="bar"><div class="bar-body"><img src="https://img.alicdn.com/tfs/TB1cm8nJwDqK1RjSZSyXXaxEVXa-160-160.png" class="front-img"/><span>文档</span><img src="https://img.alicdn.com/tfs/TB1cm8nJwDqK1RjSZSyXXaxEVXa-160-160.png" class="back-img"/></div></div><section class="content-section"><div class="sidemenu"><div class="sidemenu-toggle"><img src="https://img.alicdn.com/tfs/TB1E6apXHGYBuNjy0FoXXciBFXa-200-200.png"/></div><ul><li class="menu-item menu-item-level-1"><span>概述</span><ul><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><a href="/zh-cn/docs/overview/what-is-seata.html" target="_self">Seata 是什么？</a></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><a href="/zh-cn/docs/overview/terminology.html" target="_self">术语表</a></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><a href="/zh-cn/docs/overview/faq.html" target="_self">FAQ</a></li></ul></li><li class="menu-item menu-item-level-1"><span>用户文档</span><ul><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><a href="/zh-cn/docs/user/quickstart.html" target="_self">快速启动</a></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><a href="/zh-cn/docs/user/saga.html" target="_self">Saga 模式</a></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><a href="/zh-cn/docs/user/configurations.html" target="_self">参数配置</a></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><a href="/zh-cn/docs/user/transaction-group.html" target="_self">事务分组介绍</a></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><a href="/zh-cn/docs/user/spring.html" target="_self">Spring 支持</a></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><a href="/zh-cn/docs/user/api.html" target="_self">API 支持</a></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><a href="/zh-cn/docs/user/microservice.html" target="_self">微服务框架支持</a></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><a href="/zh-cn/docs/user/ormframework.html" target="_self">ORM 框架支持</a></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><a href="/zh-cn/docs/user/datasource.html" target="_self">数据源类型支持</a></li></ul></li><li class="menu-item menu-item-level-1"><span>开发者指南</span><ul><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><span>各事务模式<img style="transform:rotate(-90deg)" class="menu-toggle" src="/img/system/arrow_down.png"/></span><ul><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/dev/mode/at-mode.html" target="_self">Seata AT 模式</a></li><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/dev/mode/tcc-mode.html" target="_self">Seata TCC 模式</a></li><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/dev/mode/saga-mode.html" target="_self">Seata Saga 模式</a></li></ul></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><a href="/zh-cn/docs/dev/seata-mertics.html" target="_self">Metrics设计</a></li></ul></li><li class="menu-item menu-item-level-1"><span>运维指南</span><ul><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><a href="/zh-cn/docs/ops/operation.html" target="_self">Metrics配置</a></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><span>部署<img style="transform:rotate(-90deg)" class="menu-toggle" src="/img/system/arrow_down.png"/></span><ul><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/ops/deploy-guide-beginner.html" target="_self">新人文档</a></li><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/ops/deploy-server.html" target="_self">直接部署</a></li><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/ops/deploy-by-docker.html" target="_self">Docker部署</a></li><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/ops/deploy-by-kubernetes.html" target="_self">Kubernetes部署</a></li><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/ops/deploy-by-helm.html" target="_self">Helm 部署</a></li></ul></li></ul></li></ul></div><div class="doc-content markdown-body"><h1>使用 Kubernetes 部署 Seata Server</h1>
<h3>快速启动</h3>
<p>创建 <code>seata-server.yaml</code></p>
<pre><code class="language-yaml"><span class="hljs-attr">apiVersion:</span> <span class="hljs-string">v1</span>
<span class="hljs-attr">kind:</span> <span class="hljs-string">Service</span>
<span class="hljs-attr">metadata:</span>
<span class="hljs-attr">  name:</span> <span class="hljs-string">seata-server</span>
<span class="hljs-attr">  namespace:</span> <span class="hljs-string">default</span>
<span class="hljs-attr">  labels:</span>
<span class="hljs-attr">    k8s-app:</span> <span class="hljs-string">seata-server</span>
<span class="hljs-attr">spec:</span>
<span class="hljs-attr">  type:</span> <span class="hljs-string">NodePort</span>
<span class="hljs-attr">  ports:</span>
<span class="hljs-attr">    - port:</span> <span class="hljs-number">8091</span>
<span class="hljs-attr">      nodePort:</span> <span class="hljs-number">30091</span>
<span class="hljs-attr">      protocol:</span> <span class="hljs-string">TCP</span>
<span class="hljs-attr">      name:</span> <span class="hljs-string">http</span>
<span class="hljs-attr">  selector:</span>
<span class="hljs-attr">    k8s-app:</span> <span class="hljs-string">seata-server</span>

<span class="hljs-meta">---</span>

<span class="hljs-attr">apiVersion:</span> <span class="hljs-string">apps/v1</span>
<span class="hljs-attr">kind:</span> <span class="hljs-string">Deployment</span>
<span class="hljs-attr">metadata:</span>
<span class="hljs-attr">  name:</span> <span class="hljs-string">seata-server</span>
<span class="hljs-attr">  namespace:</span> <span class="hljs-string">default</span>
<span class="hljs-attr">  labels:</span>
<span class="hljs-attr">    k8s-app:</span> <span class="hljs-string">seata-server</span>
<span class="hljs-attr">spec:</span>
<span class="hljs-attr">  replicas:</span> <span class="hljs-number">1</span>
<span class="hljs-attr">  selector:</span>
<span class="hljs-attr">    matchLabels:</span>
<span class="hljs-attr">      k8s-app:</span> <span class="hljs-string">seata-server</span>
<span class="hljs-attr">  template:</span>
<span class="hljs-attr">    metadata:</span>
<span class="hljs-attr">      labels:</span>
<span class="hljs-attr">        k8s-app:</span> <span class="hljs-string">seata-server</span>
<span class="hljs-attr">    spec:</span>
<span class="hljs-attr">      containers:</span>
<span class="hljs-attr">        - name:</span> <span class="hljs-string">seata-server</span>
<span class="hljs-attr">          image:</span> <span class="hljs-string">docker.io/seataio/seata-server:latest</span>
<span class="hljs-attr">          imagePullPolicy:</span> <span class="hljs-string">IfNotPresent</span>
<span class="hljs-attr">          env:</span>
<span class="hljs-attr">            - name:</span> <span class="hljs-string">SEATA_PORT</span>
<span class="hljs-attr">              value:</span> <span class="hljs-string">"8091"</span>
<span class="hljs-attr">            - name:</span> <span class="hljs-string">STORE_MODE</span>
<span class="hljs-attr">              value:</span> <span class="hljs-string">file</span>
<span class="hljs-attr">          ports:</span>
<span class="hljs-attr">            - name:</span> <span class="hljs-string">http</span>
<span class="hljs-attr">              containerPort:</span> <span class="hljs-number">8091</span>
<span class="hljs-attr">              protocol:</span> <span class="hljs-string">TCP</span>
</code></pre>
<pre><code class="language-bash">$ kubectl apply -f seata-server.yaml
</code></pre>
<h2>自定义配置</h2>
<h3>环境变量</h3>
<p>支持的环境变量和 Docker 相同，可以参考 <a href="./deploy-by-docker.md">使用 Docker 部署 Seata Server</a></p>
<h3>使用自定义配置文件</h3>
<p>指定配置文件可以通过挂载的方式实现，如将<code>/root/workspace/seata/seata-config/file</code>  下的配置文件挂载到pod 中，挂载后需要通过指定 <code>SEATA_CONFIG_NAME</code> 指定配置文件位置，并且环境变量的值需要以<code>file:</code>开始, 如: <code>file:/root/seata-config/registry</code></p>
<ul>
<li>Deployment</li>
</ul>
<pre><code class="language-yaml"><span class="hljs-attr">apiVersion:</span> <span class="hljs-string">apps/v1</span>
<span class="hljs-attr">kind:</span> <span class="hljs-string">Deployment</span>
<span class="hljs-attr">metadata:</span>
<span class="hljs-attr">  name:</span> <span class="hljs-string">seata-server</span>
<span class="hljs-attr">  namespace:</span> <span class="hljs-string">default</span>
<span class="hljs-attr">  labels:</span>
<span class="hljs-attr">    k8s-app:</span> <span class="hljs-string">seata-server</span>
<span class="hljs-attr">spec:</span>
<span class="hljs-attr">  replicas:</span> <span class="hljs-number">1</span>
<span class="hljs-attr">  selector:</span>
<span class="hljs-attr">    matchLabels:</span>
<span class="hljs-attr">      k8s-app:</span> <span class="hljs-string">seata-server</span>
<span class="hljs-attr">  template:</span>
<span class="hljs-attr">    metadata:</span>
<span class="hljs-attr">      labels:</span>
<span class="hljs-attr">        k8s-app:</span> <span class="hljs-string">seata-server</span>
<span class="hljs-attr">    spec:</span>
<span class="hljs-attr">      containers:</span>
<span class="hljs-attr">        - name:</span> <span class="hljs-string">seata-server</span>
<span class="hljs-attr">          image:</span> <span class="hljs-string">docker.io/seataio/seata-server:latest</span>
<span class="hljs-attr">          imagePullPolicy:</span> <span class="hljs-string">IfNotPresent</span>
<span class="hljs-attr">          env:</span>
<span class="hljs-attr">            - name:</span> <span class="hljs-string">SEATA_PORT</span>
<span class="hljs-attr">              value:</span> <span class="hljs-string">"8091"</span>
<span class="hljs-attr">            - name:</span> <span class="hljs-string">STORE_MODE</span>
<span class="hljs-attr">              value:</span> <span class="hljs-string">file</span>
<span class="hljs-attr">            - name:</span> <span class="hljs-string">SEATA_CONFIG_NAME</span>
<span class="hljs-attr">              value:</span> <span class="hljs-attr">file:/root/seata-config/registry</span>
<span class="hljs-attr">          ports:</span>
<span class="hljs-attr">            - name:</span> <span class="hljs-string">http</span>
<span class="hljs-attr">              containerPort:</span> <span class="hljs-number">8091</span>
<span class="hljs-attr">              protocol:</span> <span class="hljs-string">TCP</span>
<span class="hljs-attr">          volumeMounts:</span>
<span class="hljs-attr">            - name:</span> <span class="hljs-string">seata-config</span>
<span class="hljs-attr">              mountPath:</span> <span class="hljs-string">/root/seata-config</span>
<span class="hljs-attr">      volumes:</span>
<span class="hljs-attr">        - name:</span> <span class="hljs-string">seata-config</span>
<span class="hljs-attr">          hostPath:</span>
<span class="hljs-attr">            path:</span> <span class="hljs-string">/root/workspace/seata/seata-config/file</span>
</code></pre>
</div></section><footer class="footer-container"><div class="footer-body"><img src="/img/seata_logo_gray.png"/><p class="docsite-power">website powered by docsite</p><div class="cols-container"><div class="col col-12"><h3>愿景</h3><p>Seata 是一款阿里巴巴开源的分布式事务解决方案，致力于在微服务架构下提供高性能和简单易用的分布式事务服务。</p></div><div class="col col-6"><dl><dt>文档</dt><dd><a href="/zh-cn/docs/overview/what-is-seata.html" target="_self">Seata 是什么？</a></dd><dd><a href="/zh-cn/docs/user/quickstart.html" target="_self">快速开始</a></dd><dd><a href="https://github.com/seata/seata.github.io/issues/new" target="_self">报告文档问题</a></dd><dd><a href="https://github.com/seata/seata.github.io" target="_self">在Github上编辑此文档</a></dd></dl></div><div class="col col-6"><dl><dt>资源</dt><dd><a href="/zh-cn/blog/index.html" target="_self">博客</a></dd><dd><a href="/zh-cn/community/index.html" target="_self">社区</a></dd></dl></div></div><div class="copyright"><span>Copyright © 2019 Seata</span></div></div></footer></div></div>
	<script src="https://f.alicdn.com/react/15.4.1/react-with-addons.min.js"></script>
	<script src="https://f.alicdn.com/react/15.4.1/react-dom.min.js"></script>
	<script>
		window.rootPath = '';
  </script>
	<script src="/build/documentation.js"></script>
	<script>
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?104e73ef0c18b416b27abb23757ed8ee";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
    </script>
</body>
</html>
